home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / viewkit / xcontact / lib / OkTextPat.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  2.2 KB  |  64 lines

  1. /*
  2.  * Copyright (C) 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. #pragma once
  18.  
  19. #include "OkStr.h"
  20.  
  21. // Abstract class for searches
  22.  
  23. class OkTextPat {
  24. private:
  25. public:
  26.     OkTextPat();
  27.     virtual ~OkTextPat();
  28.  
  29.     // find the string in a buffer of length buflen. Null characters
  30.     // may be considered to be the end of the buffer. If the string
  31.     // is not found, a -1 is returned.
  32.     int find(char* b, u_int bl) 
  33.     { return findBuffer(b, bl); }
  34.     int find(char* c) 
  35.     { return findBuffer(c, strlen(c)); }
  36.     int find(OkStr& s) 
  37.     { return findBuffer(s, s.length()); }
  38.  
  39.     // find the end of the string, after the next occurrence.
  40.     // If the string is not found, 0 is returned.
  41.     int findEnd(char* b, u_int bl) 
  42.     { return findEndBuffer(b, bl); }
  43.     int findEnd(char* c) 
  44.     { return findEndBuffer(c, strlen(c)); }
  45.     int findEnd(OkStr & s)
  46.     { return findEndBuffer(s, s.length()); }
  47.  
  48.     // find the beginning and end of the first occurrence of the string
  49.     // in a null-terminated buffer. If the string is
  50.     // not found, start=-1 and end=0.
  51.     void bracket(char* b, u_int bl, int& start, int& end) 
  52.     { bracketBuffer(b, bl, start, end); }
  53.     void bracket(char* c, int& start, int& end) 
  54.     { bracketBuffer(c, strlen(c), start, end); }
  55.     void bracket(OkStr& s, int& start, int& end) 
  56.     { bracketBuffer(s, s.length(), start, end); }
  57.  
  58. protected:
  59.     virtual int findBuffer(char*, u_int)  = 0;
  60.     virtual int findEndBuffer(char*, u_int)  = 0;
  61.     virtual void bracketBuffer(char*, u_int, int&, int&)  = 0;
  62. };
  63.  
  64.